import unittest
from HTMLTestRunner_PY3 import HTMLTestRunner
import time

# HTMLTestRunner_PY3 # 带一个圆形图

if __name__ == '__main__':
    test_dir = r'..\test_case'
    discover = unittest.defaultTestLoader.discover(test_dir, pattern='test*.py')  # 批量加载测试用例

    report_dir = r'..\reports'      # 定义输出html的路径
    now = time.strftime('%Y-%m-%d %H_%M_%S')    # 获取一个当前时间
    report_name = rf'{report_dir}\{now}report.html'

    with open(report_name, mode='wb')as f:
        runner = HTMLTestRunner(f, title='测试报告',description='测试详情')
        runner.run(discover)
